<template>
  <div class="app-container">
    <el-button @click="cancel">返 回</el-button>

    <el-table v-loading="loading" :data="examList" style="width: 100%;padding-top: 20px">
      <!--      <el-table-column label="工龄报名" align="center" key="seniorityFlag">-->
      <!--        <template slot-scope="scope">-->
      <!--          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.seniorityFlag"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="2000年前毕业" align="center" key="eduFlag">-->
      <!--        <template slot-scope="scope">-->
      <!--          <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.eduFlag"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->

      <el-table-column label="报名职业/等级" align="center" prop="vocationText"/>
      <el-table-column label="申报时间" align="center" prop="createTime"/>
      <el-table-column label="状态" align="center" key="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.exam_status" :value="scope.row.status"/>
        </template>
      </el-table-column>


      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="normal"
            type="text"
            icon="el-icon-edit"
            @click="handleDelete(scope.row)"
            v-hasPermi="['h5:exam:remove']"
            v-if="scope.row.status==='00'"
          >撤销
          </el-button>
          <el-button
            size="normal"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-if="scope.row.status==='10'"
            v-hasPermi="['h5:exam:query']"
          >修改
          </el-button>
          <el-button
            size="normal"
            type="text"
            icon="el-icon-download"
            @click="handleExportPdf(scope.row)"
            v-if="scope.row.status==='30'"
            v-hasPermi="['h5:exam:export']"
          >下载
          </el-button>


          <!--          <el-button-->
          <!--            size="mini"-->
          <!--            type="text"-->
          <!--            icon="el-icon-delete"-->
          <!--            @click="handleDelete(scope.row)"-->
          <!--            v-hasPermi="['system:exam:remove']"-->
          <!--          >删除</el-button>-->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />


    <el-row style="padding-bottom: 50px"></el-row>
  </div>
</template>

<script>
import {wechatListExam, delExam } from "@/api/system/weChatExam"

export default {
  name: "BaomingData",
  dicts: ['exam_status', 'sys_yes_no'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 考试报名表格数据
      examList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        seniorityFlag: null,
        eduFlag: null,
        vocation: null,
        level: null,
        status: null,
        tenantId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        userId: [
          {required: true, message: "用户ID不能为空", trigger: "blur"}
        ],
      },
      vocationList: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    handleExportPdf(row) {
      this.download('system/exam/exportPdf', {examId: row.examId}, `资料_${new Date().getTime()}.pdf`)
    },


    /** 查询考试报名列表 */
    getList() {
      this.loading = true
      wechatListExam(this.queryParams).then(response => {
        this.examList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    // 取消按钮
    cancel() {
      this.$router.push({path: "/kaoshi/shouye"}).catch(() => {})
    },

    /** 修改按钮操作 */
    handleUpdate(row) {
      this.$router.push({path: "/kaoshi/baomingEdit/"+row.examId}).catch(() => {})

      // this.reset()
      // const examId = row.examId || this.ids
      // getExam(examId).then(response => {
      //   this.form = response.data
      //   this.open = true
      //   this.title = "修改考试报名"
      // })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const examIds = row.examId || this.ids
      this.$modal.confirm('是否确认撤销此项报名数据，撤销后无法恢复？').then(function () {
        return delExam(examIds)
      }).then(() => {
        this.getList()
        this.$modal.msgSuccess("撤销成功")
      }).catch(() => {
      })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/exam/export', {
        ...this.queryParams
      }, `exam_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
<style scoped lang="scss">
html, body {
  overscroll-behavior: contain; /* 禁止惯性滚动 */
  height: 100%;
  overflow: hidden; /* 根据实际需求调整 */
}

::-webkit-scrollbar-button {
  display: none; /* 消除下拉箭头 */
}

.login {
  width: 100vw;
  touch-action: pan-y;
  display: grid;
  justify-content: center;
  align-items: center;
  overflow-y: hidden;
}
</style>
